package Kuaishou;

import java.util.List;

import com.google.common.collect.Lists;

/**
 * 计算耗时测试
 *
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2021-07-26
 */
public class Test45 {
    public static void main(String[] args) {
        List<Integer> list = Lists.newArrayList();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }
        long start = System.currentTimeMillis();
        int sum = 0;

        for (int i : list) {
            if ((i & 1) == 1) {
                sum += i;
            } else {
                sum -= i;
            }
        }

        long cost = System.currentTimeMillis() - start;
        System.out.println("结果：" + sum + "耗时: " + cost);
    }
}
